// 功能：1 创建 关闭连接 2 菜单打印 3 用户输入处理 
#include <stdio.h>
#include <stdlib.h>
#include "database.h"

void printf_menu()
{
    printf("\n===== 门诊排班系统 =====\n");
    printf("1. 科室管理\n");
    printf("2. 医生管理\n");
    printf("3. 排班管理\n");
    printf("4. 门诊管理\n");
    printf("5. 就诊人管理\n");
    printf("6. 挂号管理\n");
    printf("7. 排号管理\n");
    printf("0. 退出系统\n");
    printf("=======================\n");
    printf("请输入你的选择: ");
}
int main()
{
    MYSQL conn;
    MYSQL* pconn = connect_init(&conn);
    //初始化数据库
    Init_database(pconn);
    int choice;
    do{
        printf_menu();
        scanf("%d", &choice);
        getchar();  // 将换行符读取
        switch (choice)
        {
            case 1:
                manage_departments(pconn);
                break;
            case 2:
                manage_doctors(pconn);
                break;
            case 3:
                manage_schedules(pconn);
                break;
            case 4:
                manage_clinics(pconn);
                break;
            case 5:
                manage_patients(pconn);
                break;
            case 6:
                manage_registrations(pconn);
                break;
            case 7:
                manage_queue(pconn);
                break;
            case 0:
                printf("退出系统...\n");
                break;
            default:
                printf("无效的选择，请重新输入。\n");
        }
    }while(choice != 0);

    mysql_close(pconn);
    
    return 0;
}